import React from 'react'
import { connect } from 'react-redux'

class ComA extends React.Component {
  handleClick = () => {
    this.props.sendAction()
  }

  render() {
    return <button onClick={this.handleClick}>add</button>
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    sendAction: () => {
      dispatch({
        type: 'add_action',
      })
    },
  }
}
//作为发送方 用connect的第二个参数 mapDispatchToProps 会把 返回值挂载到this.props
export default connect(null, mapDispatchToProps)(ComA)
